<?php
namespace haibao\cms\business\attendance;

use haibao\app\business\BusinessException;
Class AttendanceApproved extends \haibao\cms\business\Base{
	
	public static function addApprovedRecord($model){
		if(empty($model->JobNum)){
			throw new BusinessException('工号不能为空',self::DATA_EMPTY);
		}
		if(empty($model->AttendanceCyc)){
			throw new BusinessException('考勤周期不能为空',self::DATA_EMPTY);
		}
		$data = new \haibao\cms\data\attendance\AttendanceApproved();
		$data->add($model);
	}
	
	public static function getApprovedRecord($filter,$isOne = true){
		$data = new \haibao\cms\data\attendance\AttendanceApproved();
		if($isOne){
			return $data->getOne($filter);
		}else{
			return $data->getAll($filter);
		}
	}
	
	public static function updateApprovedById($id,$arrSet){
		$data = new \haibao\cms\data\attendance\AttendanceApproved();
		return $data->updateById($id, $arrSet);
	}
	
	public static function delApprovedAttendance($jobNum,$endDate){
		if(empty($endDate)){
			throw new BusinessException('结束时间不能为空',self::DATA_EMPTY);
		}
		$data = new \haibao\cms\data\attendance\AttendanceApproved();
		return $data->delApprovedAttendance( $jobNum,$endDate);	
	}
	
	public static function getApprovedRecordByJobNumAndCycle($jobNum,$date){
		if(empty($jobNum)){
			throw new BusinessException('员工工号不能为空',self::DATA_EMPTY);
		}
		if(empty($date)){
			throw new BusinessException('考勤周期不能为空',self::DATA_EMPTY);
		}
		$data = new \haibao\cms\data\attendance\AttendanceApproved();
		return $data->getApprovedRecordByJobNumAndCycle( $jobNum,$date);	
		
	}
}